package cn.jbit.supermarker.service.impl;

import java.util.List;

import cn.jbit.supermarker.dao.ProviderDao;
import cn.jbit.supermarker.dao.impl.ProviderDaoImpl;
import cn.jbit.supermarker.entity.Provider;
import cn.jbit.supermarker.service.ProviderService;

import com.sun.org.apache.bcel.internal.generic.NEW;


public class ProviderServiceImpl implements ProviderService {
	public static void main(String[] args) {
		ProviderServiceImpl providerServiceImpl=new ProviderServiceImpl();
		Provider pro=new Provider();
		//添加
//		pro.setPro_name("北京丰台区");
//		pro.setPro_desc("是个饮料加工厂");
//		pro.setPro_contact("李四");
//		pro.setPro_phone("124555");
//		pro.setPro_address("丰台开发区");
//		pro.setPro_fax("9483223");
//		boolean flag=providerServiceImpl.addProvider(pro);
		//修改信息、
//		pro.setPro_id(4);
//		pro.setPro_contact("赵四");
//		pro.setPro_name("北京通州");
//		boolean flag=providerServiceImpl.updateProviderl(pro);
		//删除信息
//		pro.setPro_id(2);
//		boolean flag=providerServiceImpl.deleteProvider(pro);
		//查询
//		List<Provider> providerList=providerServiceImpl.getProPageList(0, 2, "百事");
		//List<Provider> providerList=providerServiceImpl.getProviderList();
//		for (Provider prov : providerList) {
//			System.out.println(prov.getPro_name()+"\t"+prov.getPro_desc()+"\t"+prov.getPro_contact());
//		}
		int totalCount=providerServiceImpl.getTotalCount("北京");
		System.out.println(totalCount);
//		if(flag){
//			System.out.println("成功");
//		}else{
//			System.out.println("失败");
//		}
	}
	
	private ProviderDao providerDao=new ProviderDaoImpl();
	
	public ProviderDao getProviderDao() {
		return providerDao;
	}

	public void setProviderDao(ProviderDao providerDao) {
		this.providerDao = providerDao;
	}

	
	public List<Provider> getProviderList() {
		// TODO Auto-generated method stub
		return providerDao.getProviderList();
	}

	
	public boolean addProvider(Provider provider) {
		// TODO Auto-generated method stub
		return providerDao.addProvider(provider);
	}

	
	public boolean updateProviderl(Provider provider) {
		// TODO Auto-generated method stub
		return providerDao.updateProviderl(provider);
	}

	
	public boolean deleteProvider(int id) {
		// TODO Auto-generated method stub
		return providerDao.deleteProvider(id);
	}

	
	public Provider getProById(int id) {
		// TODO Auto-generated method stub
		return providerDao.getProById(id);
	}

	
	public List<Provider> getProPageList(int pageNo, int pageSize,String proName) {
		// TODO Auto-generated method stub
		return providerDao.getProPageList(pageNo, pageSize,proName);
	}

	public int getTotalCount(String proName) {
		// TODO Auto-generated method stub
		return providerDao.getTotalCount(proName);
	}

}
